import axios from 'axios'
import qs from 'qs'

let instance = axios.create({
	baseURL: 'http://localhost:2345',
	timeout: 5000
})

instance.interceptors.request.use(
	(config) => {
		config.method == 'post' ? config.data = qs.stringify({ ...config.data
		}) : config.params = { ...config.params }
		return config
	},
	(error) => {
		return Promise.reject(error)
	}
)

instance.interceptors.response.use(
	(response) => {
		return response.data
	},
	(error) => {
		return Promise.reject(error)
	}
)

export default instance
// export default fengzhuang0
